﻿@{
    ViewBag.Title = "Home Page";
    Layout = null;
}

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Rating</title>
</head>
<body>
<h2>Please rate</h2>
<input type="button" id="vote" value="Good (0)" />
    <script src="~/Scripts/jquery-1.10.2.js"></script>
    <script src="~/Scripts/jquery.signalR-2.2.2.js"></script>

<script type="text/javascript">
    $(function () {
        var con = $.hubConnection();
             
        var hub = con.createHubProxy("rateHub");
            
        hub.on('rateUpdate', function (count) {
            $('#vote').val("Good (" + count + ")");
        });

        con.start().done(function () {
            $('#vote').click(function () {
                hub.invoke("Rate");
            });
        });
    });
</script>
</body>
</html>